package de.haw.halloWorld;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Prefs {
	
	public static Context contextOfApplication; 
	private final String VERSION_NUMBER = "version"; 
	
	// save an integer in the SharedPreferences 
	public void saveVersion(int version){
		contextOfApplication = MainActivity.getContextOfApllication(); 
		
		SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(contextOfApplication); 
		SharedPreferences.Editor editor = sp.edit();
		editor.putInt(VERSION_NUMBER, version);
		editor.commit();
		System.out.println("save " + version);
	}
	
	public int loadVersion(){
		contextOfApplication = MainActivity.getContextOfApllication(); 

		SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(contextOfApplication);
		int currentVersion = sp.getInt(VERSION_NUMBER, 0);
		return currentVersion;
	}
}
